package com.springcloud1.provider.controller;

import com.netflix.discovery.DiscoveryClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;

@Api(tags = "用户信息")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    Environment environment;

//    @Autowired
//    DiscoveryClient discoveryClient;

    @ApiOperation(value = "返回默认用户信息",notes = "")
    @GetMapping()
    public String getUser() {

        //测试Hystrix放开
//        try {
//            Thread.sleep(10000);
//        }catch(Exception e) {}

        return "my name is zhangsan，"+environment.getProperty("local.server.port");
    }
    @ApiOperation(value = "返回查询用户信息",notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "要显示的用户名",required = true,dataType = "String")
    })
    @GetMapping("/{name}")
    public String getHelloUser(@PathVariable String name){
        return "Hello "+name+",good day";
    }
}
